package com.changpay.zywy.ui.activity.count
import com.changpay.zywy.R
import com.changpay.zywy.base.BaseActivity
import com.changpay.zywy.base.IView
import com.changpay.zywy.ext.showToast
import com.changpay.zywy.ext.sss
import com.changpay.zywy.http.RetrofitHelper
import com.changpay.zywy.utils.DateUtil
import kotlinx.android.synthetic.main.activity_qu_dao_trand_count.*
import kotlinx.android.synthetic.main.title_layout.*


class CountQuDaoTrandActivity : BaseActivity(), IView,CountTrandMemberView.CountChartActionClose {
    override fun loadTrandMemberCharData(month: String?) {

        val param = hashMapOf<String, String>()
        param["key"] = token
        param["month"] = month!!
        param["gc_id"] = intent.getStringExtra("gc_id")
        RetrofitHelper.service.get_channel_trading_month(param).sss(this)
        {
            count_chart_qu_dao_trand.setData(it.result.channel_trading)
        }
    }


    override fun attachLayoutRes(): Int {
        return R.layout.activity_qu_dao_trand_count
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

    override fun showDefaultMsg(msg: String) {
        showToast(msg)
    }

    override fun showMsg(msg: String) {
        showToast(msg)
    }

    override fun showError(errorMsg: String) {
        showToast(errorMsg)
    }




    override fun initData() {
    }

    override fun initView() {
        tv_title.text = "月交易量"
        iv_back.setOnClickListener { finish() }
        count_chart_qu_dao_trand.setFragmentManager(supportFragmentManager)
        count_chart_qu_dao_trand.setListener(this)
    }

    override fun start() {

        val param = hashMapOf<String, String>()
        param["key"] = token
        param["month"] = DateUtil.getYearMonth(System.currentTimeMillis())
        param["gc_id"] = intent.getStringExtra("gc_id")
        RetrofitHelper.service.get_channel_trading_month(param).sss(this)
        {
            count_chart_qu_dao_trand.setData(it.result.channel_trading)
        }
    }
}
